﻿using System;
using System.Windows.Controls;
using ISRecord.View.Services;


namespace ISRecord.View
{
    public class HijriDateRule:ValidationRule
    {

        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            string s = (string)value;
            string unmaskedDate;
            try
            {
                unmaskedDate = Helper.UnmaskDate(s);
            }
            catch (FormatException)
            {

                return new ValidationResult(false, "التاريخ غير صحيح");
            }
                        
            if (!Helper.IsValidDate(unmaskedDate))
            {
                return new ValidationResult(false, "التاريخ غير صحيح.");
            }
            return new ValidationResult(true, null);
            
        }
    }
}
